package com.arpa.oms.domain.entity;

import com.arpa.wms.domain.entity.BasicEntity;
import com.arpa.wms.domain.entity.ValidList;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * OMS调拨单
 * </p>
 *
 * @author LEO
 * @since 2020-11-17
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="OmsAllocation对象", description="OMS调拨单")
public class OmsAllocation extends BasicEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "调拨单号")
    @TableField("code")
    @NotEmpty(message = "调拨单号不能为空", groups = Update.class)
    private String code;

    @ApiModelProperty(value = "调出仓库")
    @TableField("source_warehouse_code")
    @NotEmpty(message = "调出仓库不能为空！", groups = {Save.class, Update.class})
    private String sourceWarehouseCode;

    @ApiModelProperty(value = "调入仓库")
    @TableField("target_warehouse_code")
    @NotEmpty(message = "调入仓库不能为空！", groups = {Save.class, Update.class})
    private String targetWarehouseCode;

    @ApiModelProperty(value = "调出仓库名称")
    @TableField("source_warehouse_name")
    @NotEmpty(message = "调出仓库名称不能为空！", groups = {Save.class, Update.class})
    private String sourceWarehouseName;

    @ApiModelProperty(value = "调入仓库名称")
    @TableField("target_warehouse_name")
    @NotEmpty(message = "调入仓库名称不能为空！", groups = {Save.class, Update.class})
    private String targetWarehouseName;

    @ApiModelProperty(value = "入驻商")
    @TableField("shipment_code")
    @NotEmpty(message = "货主不能为空！", groups = {Save.class, Update.class})
    private String shipmentCode;

    @ApiModelProperty(value = "货主名称")
    @TableField("shipment_name")
    @NotEmpty(message = "货主名称不能为空！", groups = {Save.class, Update.class})
    private String shipmentName;

    @ApiModelProperty(value = "所属机构")
    @TableField("group_code")
    private String groupCode;

    @ApiModelProperty(value = "基本单位数量")
    @TableField("quantity")
    @Digits(integer = 20, fraction = 6, groups = {Save.class, Update.class})
    private BigDecimal quantity;

    @ApiModelProperty(value = "单数数量")
    @TableField("unit_quantity")
    @Digits(integer = 20, fraction = 6, groups = {Save.class, Update.class})
    private BigDecimal unitQuantity;

    @ApiModelProperty(value = "基本单位出库数量")
    @TableField("outbound_quantity")
    @Digits(integer = 20, fraction = 6, groups = {Save.class, Update.class})
    private BigDecimal outboundQuantity;

    @ApiModelProperty(value = "单位出库数量")
    @TableField("unit_outbound_quantity")
    @Digits(integer = 20, fraction = 6, groups = {Save.class, Update.class})
    private BigDecimal unitOutboundQuantity;

    @ApiModelProperty(value = "基本单位入库数量")
    @TableField("inbound_quantity")
    @Digits(integer = 20, fraction = 6, groups = {Save.class, Update.class})
    private BigDecimal inboundQuantity;

    @ApiModelProperty(value = "单位入库数量")
    @TableField("unit_inbound_quantity")
    @Digits(integer = 20, fraction = 6, groups = {Save.class, Update.class})
    private BigDecimal unitInboundQuantity;

    @ApiModelProperty(value = "审核意见")
    @TableField("verify_opinion")
    private String verifyOpinion;

    @ApiModelProperty(value = "审核时间")
    @TableField("gmt_verify")
    private LocalDateTime gmtVerify;

    @ApiModelProperty(value = "审核人")
    @TableField("verify_by")
    private String verifyBy;

    @ApiModelProperty(value = "审核人姓名")
    @TableField("verify_name")
    private String verifyName;

    @ApiModelProperty(value = "状态：0 新增、1 待审核、2 审核通过、3 审核不通过、4作废")
    @TableField("status")
    @NotEmpty(message = "状态不能为空！", groups = {Save.class, Update.class})
    private String status;

    @ApiModelProperty(value = "备注")
    @TableField("remarks")
    @Length(max = 255, message = "备注长度不能大于255", groups = {Save.class, Update.class})
    private String remarks;

    @ApiModelProperty(value = "调拨单明细")
    @TableField(exist = false)
    @Valid
    private List<OmsAllocationItem> allocationItemList = new ValidList<>();

    @ApiModelProperty(value = "调拨单要删除的明细code")
    @TableField(exist = false)
    private List<String> deleteCodes;

    public interface Save {

    }

    public interface Update {

    }

}
